/* Just a reference for views */
package poler.classes
{
	import mx.core.Application;
	
	import poler.model.ModelLocator;
	import poler.view.components.Container;
	
	[Bindable]
	public class ViewReference
	{
		//View Reference
		public static const LOGIN_VIEW:int = 0;
		public static const HOME_VIEW:int = 1;
		public static const VIEW1_VIEW:int = 2;
	    //
	    private static const _amLocator:ModelLocator = ModelLocator.getInstance();
	    
	    private static function updateTitleURL(ind:int):void {
	    	var sname:String = Container(Application.application.cMenu.getChildAt(ind)).TextLabel;
	    	var st:String = "CSM - "+sname;
	    	if(sname != null){
	        	_amLocator.browserManager.setTitle(st);
	        	_amLocator.browserManager.setFragment('viewIndex='+ind.toString());
	     	}
	    }
		public static function ViewChange(param:int):int{
			updateTitleURL(param);
			_amLocator.ViewIndex = param;
			if(ModelLocator.getInstance().videoDS != null){
				trace('if(ModelLocator.getInstance().videoDS.playing)'+ModelLocator.getInstance().videoDS.playing);
			if(param == 1){
				
				if(ModelLocator.getInstance().videoDS.playing) ModelLocator.getInstance().videoDS.stop();
				ModelLocator.getInstance().videoDS.visible = false;
				ModelLocator.getInstance().videoDS.includeInLayout = false;
			}else{
				if(ModelLocator.getInstance().videoDS.playing) ModelLocator.getInstance().videoDS.stop();
				ModelLocator.getInstance().videoDS.visible = false;
				ModelLocator.getInstance().videoDS.includeInLayout = false;
			}
			}
			if(_amLocator.swfLoaderC != null){
				if(param != 1){
					    var sm:Function = (_amLocator.swfLoaderC.application["StopMovie"] as Function);
					    sm();
				}else{
						
					    var pm:Function = (_amLocator.swfLoaderC.application["PlayMovie"] as Function);
					    pm();
				}
			}
			
			return param;
		}
		
		//
	}
}